﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Audio;
namespace Audio
{
   internal class RecorderImpl : IRecorder
    {
        public event RecorderFrameHandler FrameArrived;
        public event RecorderEventHandler Started;
        public event RecorderEventHandler Stopped;
        public event RecorderEventHandler ErrorOccured;
        public event AudioNodeHandler NodeCreated;
        AudioCapture capture = null;
        public RecorderImpl()
        {
            capture = new AudioCapture();
            capture.Started += () => Started?.Invoke();
            capture.Stopped += () => Stopped?.Invoke();
            capture.FrameArrived += (pcm) => FrameArrived?.Invoke(pcm);
            capture.ErrorOccured += () => ErrorOccured?.Invoke();

        }

        public void Start()
        {    
            capture.Start();
                 
        }

        public void Stop()
        {
           capture.Stop();
        }

        public bool IsRecording()
        {
            return capture.IsCapturing();
        }
    }
}
